#!/usr/bin/env python3
# coding:utf-8
import requests
import json
server_url = 'http://0.0.0.0:8080/core/facility/'
# server_url = 'http://0.0.0.0:8080/core/module/'
"""
data =  {'status': 1, 'id': 7, 'facility_type': 1,
 'dis_order': 0, 'lat': 37.8222,
'lng': 112.641, 'description': '', 'name': '1231231',
'code': '23131', 'district_id': 1}
"""
def edit_facility():
    data = {'status': 1, 'id': 12, 'facility_type': 1,
            'dis_order': 1, 'lat': 37.8222, 'lng': 112.641,
            'description': '', 'name': 'cui3',
            'code': '231313431', 'district_id': 1}  # district_id
    url = server_url + 'edit/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())


def add_facility():
    data = {'status': 1, 'facility_type': 1,
            'dis_order': 1, 'lat': 37.8222, 'lng': 112.641,
            'description': 'test1', 'name': 'cui6',
            'code': '231d311141', 'district_id': 1}
    url = server_url + 'add/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())


def del_facility():
    data = {'id': 14}
    url = server_url + 'del/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())


######
def get_facility_by_type_id():
    data = {'id': 2}
    url = server_url + 'get_all_by_facility_type_id/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())

def get_facility_by_district_id():
    data = {'id': 1}
    url = server_url + 'get_all_by_district_id/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    print(type(r))
    print(r.json())





# edit_facility()
# add_facility()
# del_facility()
# get_facility_by_type_id()
# get_facility_by_district_id()


if __name__ == '__main__':
    pass